package br.com.imapps.util;

import java.lang.reflect.Array;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import br.com.imapps.adapter.NavDrawerListAdapter;
import br.com.imapps.bazmob.R;

import br.com.imapps.category.Act_shoes;
import br.com.imapps.fragments.HomeFragment;
import br.com.imapps.model.NavDrawerItem;

public class UtilMenuDrawer {
	///Variaveis para drawmenu
	
		private DrawerLayout mDrawerLayout;
		private ListView mDrawerList;
		private ActionBarDrawerToggle mDrawerToggle;

	    // nav drawer title
	    private CharSequence mDrawerTitle;
	 
	    // used to store app title
	    private CharSequence mTitle;
	    
	    private Fragment controlFrag = null;
	 
	    // slide menu items
	    private String[] navMenuTitles;
	    private TypedArray navMenuIcons;
	 
	    private ArrayList<NavDrawerItem> navDrawerItems;
	    private NavDrawerListAdapter adapter;
	    
	    private ViewGroup cont;
	
	//Construtor
	public void UtilMenuDrawer(){
		
		
		
	}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
		this.cont = container;
		
		return container;
		
	
	}

    //fim drawmenu variaveis

	public void menuCreate(Activity act, int ArrayId, int ArrayIcons, int LayoutId, int listSliderId){
		//###################DRAWERMENU##########################
		System.out.println("Parametros");
		System.out.println("Act-> " + act.getTitle());
		System.out.println("Array-> " + ArrayId);
		System.out.println("ArrayIcons-> " + ArrayIcons);
		System.out.println("LayoutId-> " + LayoutId);
		System.out.println("listSliderId-> " + listSliderId);
		this.mTitle = mDrawerTitle = act.getTitle();
		 
        // load slide menu items
		this.navMenuTitles = act.getResources().getStringArray(ArrayId);
 
        // nav drawer icons from resources
		this.navMenuIcons = act.getResources()
                .obtainTypedArray(ArrayIcons);
 
		System.out.println("Layout Id -> " + LayoutId);
		//System.out.println("CFindView -> " + act.findViewById(LayoutId));
		
		this.mDrawerLayout = (DrawerLayout)cont.findViewById(LayoutId);
		System.out.println("Setou mDrawerLayout -> " + this.mDrawerLayout);
		this.mDrawerList = (ListView) cont.findViewById(listSliderId);
 
		this.navDrawerItems = new ArrayList<NavDrawerItem>();
 
        // adding nav drawer items to array
        // Home
        
        ///INCLUIR NO MENU
        
        incluirMenu();
        
        // Recycle the typed array
        this.navMenuIcons.recycle();
 
        // setting the nav drawer list adapter
        this.adapter = new NavDrawerListAdapter(act.getApplicationContext(),
                navDrawerItems);
        
       
        
        this.mDrawerList.setAdapter(adapter);
 
        
     // enabling action bar app icon and behaving it as toggle button
        act.getActionBar().setDisplayHomeAsUpEnabled(true);
        act.getActionBar().setHomeButtonEnabled(true);
       
		   
		
		//############# FiNAL drawerMenu ####################
	}//fim menuCreate
	
	
	public void incluirMenu(){
		navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
        // Find People
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
        // Photos
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
        // Communities, Will add a counter here
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1), true, "22"));
        // Pages
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
        // What's hot, We  will add a counter here
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1), true, "50+"));
     // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(0, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(1, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[8], navMenuIcons.getResourceId(2, -1), true, "20+"));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[9], navMenuIcons.getResourceId(3, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[10], navMenuIcons.getResourceId(4, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(0, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(1, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[8], navMenuIcons.getResourceId(2, -1), true, "20+"));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[9], navMenuIcons.getResourceId(3, -1)));
        // Bebes
        navDrawerItems.add(new NavDrawerItem(navMenuTitles[10], navMenuIcons.getResourceId(4, -1)));
 
	}


	public DrawerLayout getmDrawerLayout() {
		return mDrawerLayout;
	}


	public void setmDrawerLayout(DrawerLayout mDrawerLayout) {
		this.mDrawerLayout = mDrawerLayout;
	}


	public ListView getmDrawerList() {
		return mDrawerList;
	}


	public void setmDrawerList(ListView mDrawerList) {
		this.mDrawerList = mDrawerList;
	}


	public ActionBarDrawerToggle getmDrawerToggle() {
		return mDrawerToggle;
	}


	public void setmDrawerToggle(ActionBarDrawerToggle mDrawerToggle) {
		this.mDrawerToggle = mDrawerToggle;
	}


	public CharSequence getmDrawerTitle() {
		return mDrawerTitle;
	}


	public void setmDrawerTitle(CharSequence mDrawerTitle) {
		this.mDrawerTitle = mDrawerTitle;
	}


	public CharSequence getmTitle() {
		return mTitle;
	}


	public void setmTitle(CharSequence mTitle) {
		this.mTitle = mTitle;
	}


	public Fragment getControlFrag() {
		return controlFrag;
	}


	public void setControlFrag(Fragment controlFrag) {
		this.controlFrag = controlFrag;
	}


	public String[] getNavMenuTitles() {
		return navMenuTitles;
	}


	public void setNavMenuTitles(String[] navMenuTitles) {
		this.navMenuTitles = navMenuTitles;
	}


	public TypedArray getNavMenuIcons() {
		return navMenuIcons;
	}


	public void setNavMenuIcons(TypedArray navMenuIcons) {
		this.navMenuIcons = navMenuIcons;
	}


	public ArrayList<NavDrawerItem> getNavDrawerItems() {
		return navDrawerItems;
	}


	public void setNavDrawerItems(ArrayList<NavDrawerItem> navDrawerItems) {
		this.navDrawerItems = navDrawerItems;
	}


	public NavDrawerListAdapter getAdapter() {
		return adapter;
	}


	public void setAdapter(NavDrawerListAdapter adapter) {
		this.adapter = adapter;
	}
	
	

}
